#include "Code.h"

// initilization
unsigned int Code::lastClientNumber = 0;
unsigned int Code::lastWorkerNumber = 0;

Code::Code() {

}

Code::Code(string type) {
    setType(type);
    setNumber(type);
}

Code::~Code() {

}

const string Code::getType() {
    return type;
}

void Code::setType(string type) {
    if (type == "cli" || type == "wrk")
        this->type = type;
}

unsigned int Code::getNumber() {
    return number;
}

void Code::setNumber(string type) {
    if (type == "cli") {
        lastClientNumber++;
        setNumber(lastClientNumber);
    } else if (type == "wrk") {
        lastWorkerNumber++;
        setNumber(lastWorkerNumber);
    }
}

string Code::printCode() {
    stringstream info;

    info << this->getType() << this->getNumber();

    return info.str();
}